package com.coolwen.controller;

import com.alibaba.fastjson.JSON;
import com.coolwen.entity.Group;
import com.coolwen.service.GroupService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by user on 2016-12-9.
 */
@Controller
@RequestMapping("/test/test/")
public class TestController {

    //引入log4j,进行日志打印
    private static final Logger LOGGER = Logger.getLogger(TestController.class);

    @Autowired
    GroupService groupService;

    @RequestMapping(value = "angluar")
    public String test1() {


        return "test/test";
    }

    /**
     * 查询出所有的团，并返回json数据
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "list")
    public List<Group> test2() {
        System.out.println("angluar----------->>>>>>>>>>>>>>>>>>>>>>js");
        LOGGER.info("------------->>>>>>>>>>>>>>"+JSON.toJSON(groupService.findAllGroup()));
        return groupService.findAllGroup();
    }
}
